/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.view.saving;

import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;
import org.primefaces.context.RequestContext;
import src.domain.saving.Menusavtrans;
import src.services.saving.MenusavtransModel;
import src.services.saving.SavtransModel;
import src.util.Messager;

/**
 * 
 * @author jay
 */
@ManagedBean
@SessionScoped
public class MenusavtransBean implements Serializable {

    private List<Menusavtrans> menus;  
    private List<SelectItem> availableSavtrx; 
    
    private MenusavtransModel menuHelper;
    private SavtransModel savtransHelper;
    
    public MenusavtransBean() {
        super();
        
        this.savtransHelper = new SavtransModel();
        this.menuHelper = new MenusavtransModel();
        this.menus = menuHelper.findAll();
        this.availableSavtrx = savtransHelper.listAll();
    }

    public List<Menusavtrans> getMenus() {
        return menus;
    }

    public List<SelectItem> getAvailableSavtrx() {
        return availableSavtrx;
    }

    public void setAvailableSavtrx(List<SelectItem> availableSavtrx) {
        this.availableSavtrx = availableSavtrx;
    }
    
    public void save() {
        RequestContext context = RequestContext.getCurrentInstance();
        boolean success;  
               
        success = menuHelper.saveData(menus);
                
        Messager.showSaveUpdateStatus(success);     
        context.addCallbackParam("success", success);  
    }
}  

    
          
    